<?php
	require 'database.php';
	
	//Get geocaches for inkslake
	$query = 	'SELECT b.ID,b.Priority,e1.Name AS EName, e2.Name AS OName, p.PName, b.DateAssigned, b.DateClosed, b.Status
				FROM BugMaster b
					INNER JOIN EmployMaster e1
						ON b.Assignee = e1.ID
					INNER JOIN EmployMaster e2
						ON b.Owner = e2.ID
					INNER JOIN ProjectMaster p
						ON b.Project = p.Project
				ORDER BY b.ID';
	$bugsinks = $db->query($query);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bugsby Tracking</title>
<link href="stylesheets/group1Site.css" rel="stylesheet" type="text/css">
<link rel="icon" href="graphics/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="graphics/favicon.ico" type="image/x-icon">
<script src="scripts/jquery-1.7.1.js"></script>
<script src="scripts/imageSwap.js"></script>
<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>

<body>
<div id="wrapper">

  <div id="banner">
    <img src="graphics/banner1.png" height="90" width="730" alt="bugsby logo">
  </div>
  
 <div id="leftcolumn">
    <div id="nav">
    	<ul>
      		<li><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('homeToolbar','','graphics/homeRed.ico',1)"><img name="homeToolbar" border="0" src="graphics/home.ico" alt="Bugsby Home" width="36" height="36">&nbsp;Home</a></li>
      		<li><a href="buglist.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Buglist','','graphics/SpiderRed.ico',1)"><img name="Buglist" border="0" src="graphics/Spider.ico" alt="Buglist" width="36" height="36">&nbsp;Bug List</a></li>
      		<li><a href="buginfo.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','graphics/infoRed.ico',1)"><img name="Image8" border="0" src="graphics/info.ico" alt="Bugsby Info" width="36" height="36">&nbsp;Info</a></li>
      		<li><a href="bugmail.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','graphics/GmailRed.ico',1)"><img name="Image9" border="0" src="graphics/Gmail.ico" alt="Email Bugsby" width="36" height="36">&nbsp;Contact</a></li>
    	</ul>
  	</div><!-- End Nav id -->
</div><!-- End leftcolumn -->

<div id="content">
<h1>Bugsby - Current Bug List</h1>
<p class="standardText">Below is a listing of the current bug entries:</p>



<table border="1">
    							<tr>
        							<th>ID</th>
                                    <th>Pri</th>
            						<th>Assignee</th>
                                    <th>Project</th>
                                    <th>Owner</th>
                                    <th>Start</th>
                                    <th>End</th>
                                    <th>Status</th>
                                    <th>Remove?</th>
                                    <th>Update?</th>
                             
	  </tr>
										<?php foreach ($bugsinks as $bugsink) : ?>
                                            <tr>
                                                <td><?php echo $bugsink['ID']; ?></td>
                                                <td><?php echo $bugsink['Priority']; ?></td>

                                                <td><?php echo $bugsink['EName']; ?></td>
                                                <td><?php echo $bugsink['PName']; ?></td>
                                                <td><?php echo $bugsink['OName']; ?></td>
                                                <td><?php echo $bugsink['DateAssigned']; ?></td>
                                                <td><?php echo $bugsink['DateClosed']; ?></td>
                                                <td><?php echo $bugsink['Status']; ?></td>
												<td><form action="verify_remove_bug.php" method="post">
                                                <input type="hidden" name="ID" value="<?php echo $bugsink['ID']; ?>" />
                                                <input type="image" SRC="graphics/cut.ico" ALT="Remove" width="36" height="36" />
                                                </form>
                                                </td>
                                                <td><form action="update_bug_form.php" method="post">
                                                <input type="hidden" name="ID" value="<?php echo $bugsink['ID']; ?>" />
                                                <input type="image" SRC="graphics/write.ico" ALT="Update" width="36" height="36" />
                                                </form>
                                                </td>
                                            </tr>              
                                    <?php endforeach; ?>
                                    </table>
                                    <br />
                                    <table>
<tr>
<td>
                    <form action="add_bug_form.php" method="post" id="add_bug">
                    <input type="image" SRC="graphics/plus.ico" width="48" height="48" ALT="Add Bug!" />
                    </form>
</td>
</tr>
<tr>
<td>
<p>Add Bug!</p>
</td>
</tr>
</table>
</div>
        			<hr>
<div id="navGraphics">
<h2>Click on a Graphic to Choose an Option:</h2>
<table width="800" border="0">
  <tr>
    <td><a href="index.html"><img src="graphics/home.png" border=0 height="128" width="128" alt="homepage icon" rel="graphics/homeRed.png" class="rollover" /></a></td>
     <td><a href="buginfo.html"><img src="graphics/info.png" border=0 height="128" width="128" alt="information icon" rel="graphics/infoRed.png" class="rollover" /></a></td>
   <td><a href="bugmail.html"><img src="graphics/Gmail.png" border=0 height="128" width="128" alt="send email icon" rel="graphics/GmailRed.png" class="rollover" /></a></td>
  </tr>
  <tr>
    <td class="standardText">Bugsby Home</td>
    <td class="standardText">Information</td>
    <td class="standardText">Contact</td>
  </tr>
</table>
</div>

<p>&nbsp;</p>
	<div id="footer">
	Site Content: <a href="mailto:cs633group1@gmail.com">CS633 Group 1</a> 
	</div><!-- End Footer -->
</div><!-- End Wrapper -->
</body>
</html>
